#!/usr/bin/env python3

import pymysql as mysqldb
import re
s = re.compile(r',')
db = mysqldb.connect(user="root",passwd="111111",host="localhost",charset="utf8")
#db.autocommit()
db.autocommit(True)
cur= db.cursor()
cur.execute("create database sanle_member")
cur.execute("use sanle_member")
cur.execute("create table student (name varchar(20),daxue varchar(50),sex varchar(10),phone decimal(11),nianji varchar(50),zhuangye varchar(100),primary key(name))")

with open('sanle_member.txt') as f:
    for i in f:
        name_n,daxue_n,sex_n,phone_n,nianji_n,zhuangye_n = s.split(i)[0], s.split(i)[1], s.split(i)[2], s.split(i)[3], s.split(i)[4], s.split(i)[5]
        print(i)
        cur.execute("insert into student (name,daxue,sex,phone,nianji,zhuangye) values (name_n,daxue_n,sex_n,phone_n,nianji_n,zhuangye_n)")

cur.execute("select * from student")
datas = db.fetchall()
for i in datas:
    print(i)

db.close()
